#ifndef __I2C_H
#define __I2C_H

#include "delay.h"
#include "stm32f4xx_hal_gpio.h"

#define IIC_SCL_PIN     GPIO_PIN_8
#define IIC_SCL_PORT    GPIOB
#define IIC_SDA_PIN     GPIO_PIN_9
#define IIC_SDA_PORT    GPIOB

#define IIC_SCL_H       HAL_GPIO_WritePin(IIC_SCL_PORT, IIC_SCL_PIN, GPIO_PIN_SET)
#define IIC_SCL_L       HAL_GPIO_WritePin(IIC_SCL_PORT, IIC_SCL_PIN, GPIO_PIN_RESET)
#define IIC_SDA_H       HAL_GPIO_WritePin(IIC_SDA_PORT, IIC_SDA_PIN, GPIO_PIN_SET)
#define IIC_SDA_L       HAL_GPIO_WritePin(IIC_SDA_PORT, IIC_SDA_PIN, GPIO_PIN_RESET)
#define IIC_READ_SDA    HAL_GPIO_ReadPin(GPIOB, IIC_SDA_PIN)

#define IIC_DELAY       delay_us(2)

void MN_IIC_Init(void);
void MN_IIC_Start(void);
void MN_IIC_Stop(void);
void MN_IIC_Send_byte(uint8_t data);
uint8_t MN_IIC_WaitACK(int16_t timeout);
uint8_t MN_IIC_ReadByte(uint8_t ack);

#endif  /* __I2C_H */
